﻿/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2024/5/27
 * 时间: 13:22
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.Net;
using System.IO;
using System.Drawing.Imaging;
using System.Drawing;
using System.Windows.Forms;
using System.Text;

namespace pic
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			 
			
			
			WebClient webClient = new WebClient();
			webClient.Encoding = System.Text.Encoding.UTF8;
			string html=webClient .DownloadString("https://www.tianqi.com/tekesi/");
			string[] s= html.Split(new string[] { "weather_info\">" ,"right\">"}, StringSplitOptions.None);
			string[] s1= s[1].Split(new string[] { "<i><img src=\"" ,"\"></i>"}, StringSplitOptions.None);
			string imgurl="https:"+s1[1];
			
			webClient.Headers.Add("Referer: https://www.tianqi.com/tekesi/");
			ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.SystemDefault | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
			  Byte[] imgData = webClient.DownloadData(imgurl);
			  Stream ms = new MemoryStream(imgData);
			  ms.Position = 0;
			  Image img = Image.FromStream(ms);
			 pictureBox1.Image=img;
			
			string[] s2= s[1].Split(new string[] { "<p class=\"now\"><b>" ,"</i></p>"}, StringSplitOptions.None);
			s2[1]=s2[1].Replace("</b><i>"," ");
			label1.Text=s2[1];
			
			string[] s3= s[1].Split(new string[] { "<span><b>" ,"</span>"}, StringSplitOptions.None);
			s3[1]=s3[1].Replace("</b>"," ");
			label2.Text=s3[1];
			
			string[] s4= s[1].Split(new string[] { "<dd class=\"shidu\">" ,"<dd class=\"kongqi\">"}, StringSplitOptions.None);
			s4[1]=s4[1].Replace("<b>"," ").Replace("</b>"," ").Replace("</b><b>"," ").Replace("</dd>"," ");
			label3.Text=s4[1];
			 
			
//			
//<dt><img src="https://content.pic.tianqistatic.com/content/img/202106/30/06d60286b74c17c8.jpg" alt="" class="weaone_a"></dt>
//<dd class="name"><h1>特克斯天气</h1><i><a href="/chinacity.html" title="特克斯天气预报">[切换城市]</a></i></dd>
//<dd class="week">2024年05月28日　星期二　甲辰年四月廿一 </dd>
//<dd class="weather">
//<i><img src="//static.tianqistatic.com/static/wap2018/ico1/b1.png"></i>
//<p class="now"><b>17</b><i>℃</i></p>
//<span><b>多云</b>3 ~ 18℃</span>
//</dd>
//<dd class="shidu"><b>湿度：37%</b><b>风向：东北风 3级</b><b>紫外线：强</b></dd>
//<dd class="kongqi"><h5 style="background-color:#79b800;">空气质量：优</h5><h6>PM: 4</h6><span>日出: 06:57<br />日落: 22:02</span></dd>
 
	
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		public static Image resizeImage(Image imgToResize, Size size) {
	      return (Image)(new Bitmap(imgToResize, size));
	    }
	}
}
